FROM thomsch98/php7-composer:7.1.15-fpm-composer-alpine as builder
USER root:root
ADD ./ /opt
RUN cd /opt/ && composer config -g repo.packagist composer https://packagist.laravel-china.org && composer update

# build release image
FROM swr.cn-east-2.myhuaweicloud.com/xinchao-test/php:7.1.16
COPY --from=builder /opt/ /data/wwwroot
ADD ./nginx.conf /etc/nginx
ADD ./php-fpm.conf /usr/local/etc
RUN mkdir -p /usr/share/nginx/logs
RUN touch /usr/share/nginx/logs/error.log
ENV ACTION test
WORKDIR /data/wwwroot
ENTRYPOINT rm -rf .env && cp .env.$ACTION .env && chown -R www.www /data/wwwroot /usr/share/nginx/logs && service cron start && php-fpm && nginx -g 'daemon off;'